package org.miyuki4j.cfgtool.command;

import lombok.extern.slf4j.Slf4j;
import org.miyuki4j.cfgtool.Command;
import org.miyuki4j.cfgtool.RunModeEnum;
import org.miyuki4j.cfgtool.TableConfig;


/**
 * @Desc
 * @Author miyuki4j
 * @Date 2025/7/26/星期六 15:36
 * @Version 1.0
 */
@Slf4j
public class HelpCommand implements Command {
    @Override
    public CommandEnum type() {
        return CommandEnum.HELP;
    }

    @Override
    public void execute() {
        StringBuilder sb = new StringBuilder();
        sb.append(CommandEnum.HELP.usage()).append("\n");
        // 1.run mode
        sb.append("--------------- run mode ---------------\n");
        for (RunModeEnum value : RunModeEnum.values()) {
            sb.append(value.usage()).append("\n");
        }

        // 2. command
        sb.append("--------------- command ---------------\n");
        for (CommandEnum value : CommandEnum.values()) {
            if (value == CommandEnum.HELP) {
                continue;
            }
            sb.append(value.usage()).append("\n");
            for (TableConfig.ConfigKeyEnum configKey : value.getConfigKeys()) {
                sb.append("\t").append("--").append(configKey.getValue()).append("\n");
            }
        }

        // 3.args
        sb.append("\n");
        sb.append("--------------- args ---------------\n");
        for (TableConfig.ConfigKeyEnum value : TableConfig.ConfigKeyEnum.values()) {
            sb.append(value.usage()).append("\n");
        }
        log.info("\nUsage: \n{}", sb);
    }
}
